<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <div id="dialog-message">
 	<div id="class_room_jiandao_tabs">
		 
	</div>
 </div>
 <script>
 (function(){
	 
	 //加载当前老师的教室位置
	 function loadRoomOption(){
		 $("#class_room_jiandao_tabs").html("");
		 var url ="${pageContext.request.contextPath}/edu/sysClassAction.do?method=getTeacher_Room_C";
		 var object = new Object();  
		 object.sys_class_table_id = "${param.table_id}";
		 //因为这之前的查询是把年份放在string1里面的
		 object.year = "${param.string1}"; 
		 $.ajax({
			   type: "POST",
			   url: url,
			   async:false,
			   data:object,
			   dataType:'json',
			   success: function(data){   
				if(!data ||!data.sys_Room){
						 return;
				}
				var msg =data.sys_Room; 
				 if(msg && msg.length>0 && msg[0]!=null){
					 //显示位置
					  showRoom(msg);
					 //改变位置状态
					  changRoom(data.sys_Room_Position_User);
			     }else{
			    	 $("#class_room_jiandao_tabs").html("目前没有可用教室!");
			     }
			   }
		}); 
	 }
	 //显示教室
	 function showRoom(msg){  
			 var chair ='<div name="chair" state="1" style="width:100px;height:70px;float:left;"><div style="width:40px;height:40px;margin-left:30px;background:url(${pageContext.request.contextPath}/image/chair2.png);"></div><div style="width:100px;height:30px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;"></div></div>';
    		 var x=msg[1];
    		 var y=msg[2]; 
    		 var  myclass_ggjs =$('<div style="margin:0 auto;text-align:center;"></div>');
    		 	myclass_ggjs.width(100*x);  
    			for(var i=0;i<x;i++){
    				for(var j=0;j<y;j++){ 
    					var b =$(chair);
    					myclass_ggjs.append(b);
    					b.attr("x1",i+1);
    					b.attr("y1",j+1); 
    					b.attr("table_id",msg[0]);
    					b.attr("startClass",msg[4]);
    					 
    					
    				}
    			} 
    			var title1 =$('<div style="height:40px;float:left;text-align:center;width:100%;margin-top:30px;"><b>已过期</b></div>');
    			if(msg[3]==1){
    				title1 =$('<div style="height:40px;float:left;text-align:center;width:100%;margin-top:30px;"><b>正在使用</b></div>'); 
    			}   
    		   myclass_ggjs.append(title1); 
    		   $("#class_room_jiandao_tabs").append(myclass_ggjs); 
    		  
    }
	 //改变状态
	 function changRoom(data){
		 var chairs =$("div[name=chair]");
		 for(var i =0;i<chairs.length;i++){
			 var x1 = $(chairs[i]).attr("x1");
			 var y1 = $(chairs[i]).attr("y1");
			 for(var j=0;j<data.length;j++){
				 if(x1==data[j].x1 && y1==data[j].y1){
					 $($(chairs[i]).children()[0]).css({"background":"url(${pageContext.request.contextPath}/image/user.png)"}); 
					 $($(chairs[i]).children()[1]).text(data[j].string1);
					 $($(chairs[i]).children()[1]).attr("title",data[j].string1);
				 }
			 }
		 } 
	 };
	  
	 $(function(){ 
		 loadRoomOption()
	 });
 })();
 </script>